<?php
if( !defined('BASE') ) exit('Access Denied!');

/**
 * Obullo Framework (c) 2009.
 *
 * PHP5 MVC-min Framework software for PHP 5.2.4 or newer
 *
 * @package         obullo        
 * @author          obullo.com
 * @copyright       Ersin Güvenç (c) 2009.
 * @since           Version 1.0
 * @filesource
 * @license
 */
 
 /**
 * Parent Controllers (c) 2009
 * 
 * @version 0.1
 * @version 0.2 added core functions like ob::register
 * @version 0.3 added extending to SSC, moved register
 *              functions to common.php
 * @version 0.4 added $load variable for loader support
 *              helpers, functions..
 * @version 0.5 added parent controller functionality
 * @version 0.6 added this() shortcut function
 */

define('OBULLO_VERSION', 'Obullo 1.0 @alpha9');
 
include(APP.'config'.DS.'parents'.EXT);

$_controller = $GLOBALS['d'].'.'.$GLOBALS['c'];

if(isset($parents[$_controller]))
{
    if( ! file_exists(APP.'parents'.DS.$parents[$_controller].EXT))
    throw new CommonException('Unable locate to parent controller file: '.$_controller.EXT);
    
    require(APP.'parents'.DS.$parents[$_controller].EXT); 

    eval('Class Core_Controller extends '.$parents[$_controller].'{}');
      
} else 
{   
    require(APP.'parents'.DS.'Global_controller'.EXT);
    
    eval('Class Core_Controller extends Global_controller{}');   
}

/**
* Obullo Core Class (Super Object)
*/
Class ob extends Core_Controller
{   
    /**
    * Obullo Models
    * Store all loaded Models
    * 
    * @var array
    */
    public $_mods = array();
    
    /**
    * Obullo Libraries
    * Store all loaded Libraries
    * 
    * @var array
    */
    public $_libs = array();
       
    /**
    * Obullo instance
    * 
    * @var object
    */
    private static $instance;

    /**
    * Construct func.
    * @return void
    */
    public function __construct()
    {   
        self::$instance = &$this;
    }

    /**
    * ob::instance();
    * 
    * Obullo Super Object in Every Where
    *  
    * @author Ersin Güvenç
    * @version 1.0 
    * @version 1.1 get_instance renamed and moved here
    * @return object
    */
    public static function instance()
    {       
        return self::$instance;
    } 
    
} // end class.
                          
/**
* @author  Ersin Güvenç
* 
* A Pretty Shortcut for ob::instance();
* ob::instance = $this so this() = ob::instance;
* 
*/
function this(){ return ob::instance(); }

?>
